package com.xxy.mybatispluspro.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("api/v1/redis")
public class RedisController {

    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping("get/{key}")
    public Object get(@PathVariable("key") String key){
        return  redisTemplate.opsForValue().get(key);
    }

    @PostMapping("set/{key}/{value}")
    public Object set(@PathVariable("key") String key,
                      @PathVariable("value") String value){
        redisTemplate.opsForValue().set(key,value);
        return "set success";
    }
}
